frm256PicBx &256 Color VB Picture Box Demonstration Form1, Label1 Current Directory: labDirSelected pbCancel E&XIT Label2 &Directories Label3 &Bitmap Files R lbDirList lbFileList *.bmp PicPreview PicPreviewVScroll Label4 D&rives cbDrives W pbPreview &Preview PicPreviewHScroll PicScrollBarFiller PicPreviewSource hDIBUtilH hPalette hDIBBuffer lpDIBBuffer\ @ Form_Load OldMousePtr Screen MousePointer HOURGLASS Set_ModalDlg_SysMenu frmDirSelectn StartingDir labDirSelected Captionu cbDrives Drive lbDirList SBColors GetProfileInfoa PicScrollbarFiller BackColor LoadLibrary NULL/ lbDirList_Change lbFileList pbCancel_ClickR cbDrives_Change lbFileList_DblClickU pbPreview_Click lbFileList_PathChange ListIndexe SrcXn DestX7 DestY bmpWidth bmpHeight ShowFiller PicPreview Picturep PicPreviewSourceL FName ListE DIBLoad FastExit' GlobalLock DIBWidth DIBHeight ReturnVal GlobalUnlock ScaleWidth DestWidth ScaleHeighto DestHeight PicPreviewHScrollG Visible FALSE SmallChange LargeChange5 Value PicPreviewVScrolld DeleteObjectB CreateDIBPalette hOldPalette SelectPalette RealizePalette hBitmap CreateDIBitmap CBM_INIT FindDIBBits DIB_RGB_INFO hCompatDC CreateCompatibleDC hPrevBmp SelectObject Success BitBltt SRCCOPY DeleteDC[ GlobalFree APIError0 PicPreviewHScroll_Change PicPreviewVScroll_Changee Form_Unload Cancel FreeLibrary, Section KeyName Result ResultLength GetProfileString A_Form HSysMenu GetSystemMenu RemoveMenu MF_BYPOSITION pbOK_Click9 PicBx frm256PicBx hScreenDC GetDC ReleaseDC hMyDC` Handle to our dll Handle to a palette created for previewing a bitmap Handle to a global memory area into which a DIB file has been read (for use with DIB utility routines) A pointer to the actual memory buffer containing the DIB Form_Load Remove all but Move and Close from the system menu Set up starting directoryl Colors ScrollBar" Load the DIBUTIL library" hDIBUtil = LoadLibrary("DIBUTIL.DLL") Since we haven't yet created a palette, initialize hPalette tor null to indicate this lbDirList_Change pbCancel_Click cbDrives_Change lbFileList_DblClick lbFileList_PathChange pbPreview_Click Set an hourglass cursor Clear any existing bitmaps If no bitmap file is selected, take the first onez Load the bitmap into memory and get its dimensions Error loading Set up bitblt parameters Set up the scroll bars If we have previously created a palette, delete it now (pbPreview_Click) Warning: Could not delete hPalette!" Create a new palette for this bitmap Make sure DC containing the persistent image has the right palette Make sure the picture box DC has the right paletteh Lock the memory block Create a Device Dependent Bitmap Create a memory DC from which we can bitblt the image. Select in and realize the palette, then select in the ddb hOldPalette% = SelectPalette(hCompatDC%, hPalette, FALSE)S ReturnVal% = RealizePalette(hCompatDC%), Blast the image into our hidden picture boxa Free up resources we no longer need (pbPreview_Click) Warning: Could not delete hComptDC%! (pbPreview_Click) Warning: Could not delete hBitmap%!" release previously allocated memoryn Blast the new picture into the preview picture box Restore the cursor PicPreviewHScroll_Change Set up bitblt parameters In case anyone has changed the palette since we last painted, realize it (again) Blast the new picture into the preview picture box PicPreviewVScroll_Change Set up bitblt parameters In case anyone has changed the palette since we last painted, realize it (again) Blast the new picture into the preview picture box Form_Unload if hPalette is not 0 then we've created a palette that should be deleted before we terminate the program (Form_Unload) Warning: Could not delete hPalette!" Allow Windows to unload our dll GetProfileInfo Set_ModalDlg_SysMenu Modal dialog boxes usually do not have a System menu or if they do, they consist of only MOVE and CLOSE options. This routine is called when a Modal dialog box is about to beh displayed, to remove all but the MOVE and CLOSE options from the forms system menu. IconWorks has only two Modal dialog boxes: About and SaveFileDlg Obtain the handle to the forms System menu Remove all but the MOVE and CLOSE options. The menu items must be removed starting with the last menu item to prevent the menu items from taking on new position values as othert menu items are being removed. Switch to. Separator. Separator. Maximize Minimize Restoree pbOK_Click